package com.example.materialcostsystembackend.controller;

import com.example.materialcostsystembackend.model.OrderItemDetail;
import com.example.materialcostsystembackend.service.OrderItemDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/items")
public class OrderItemDetailController {
    @Autowired
    private OrderItemDetailService service;
    public OrderItemDetailController(OrderItemDetailService service) {
        this.service = service;
    }
    // 获取所有记录
    @GetMapping("/all")
    public ResponseEntity<  List<OrderItemDetail>> getAllItems() {
        return ResponseEntity.ok(service.getAllItems());
    }

    // 获取数量 > 0 的记录
    @GetMapping("/valid")
    public ResponseEntity<List<OrderItemDetail>> getValidItems() {
        return ResponseEntity.ok(service.getValidItems());
    }


}
